<template>
    <div>
        <Label for="sg">班组</Label>
        <ComboBox
                inputId="sg"
                v-model="scheduleGroupSelects"
                :data="scheduleGroupList"
                :panelStyle="comboBoxBorder"
                style="width: 250px"
                :multiple="true"
                :textFormatter="formatText"
                :editable="false"
        ></ComboBox>
    </div>
</template>
<script>
    import sys from "@/api/sys";

    export default {
        name: "scheduleGroup",
        components: {},
        data() {
            return {
                comboBoxBorder: { border: "#bbbbbb 1px solid", height: "200px"},
                //职务集合
                scheduleGroupSelects: [],
                //岗位集合
                scheduleGroupList: []
            };
        },
        mounted() {
            this.initData()
        },
        methods: {
            //加载配置信息
            async initData() {
                this.scheduleGroupList = [];
                this.scheduleGroupSelects = [];
                /*加载基础数据*/
                let zw = await sys.getScheduleGroup();
                if (zw.success && zw.result.length > 0) {
                    zw.result.forEach(v => {
                        if (v.isEnable == 1) {
                            this.scheduleGroupList.push({
                                value: v.id,
                                text: v.groupName
                            })
                        }
                    });
                }
            },
            formatText(value) {
                if (value) {
                    value = value
                        .split(",")
                        .sort()
                        .join(",");
                }
                return value;
            },
        },
        /*获取选择的值集合*/
        getSelects(){
            return this.scheduleGroupSelects;
        }
    };
</script>
<style>
</style>
